<?php
namespace app\examScore\controller;
use app\common\Base;
use app\common\Excel;
use think\Db;
//--培优统计初一
class PeiyouTotalChuyi extends Base {
	
	public function index() {
		return $this->fetch();
	}

	public function pageQuery() {
		$examId = input("examId");
		$clazzType = input("clazzType");
		if(!$examId) return [];
		$where["考试ID"] = $examId;
		$where["实验班"] = $clazzType;
		$result = Db::table("培优统计初一")
				  ->where($where)
				  ->order("班级")
				  ->select();
		return selectResult($result);
	}

	public function exportExcel() {
		$fields = input("fields");
		$examId = input("examId");
		$clazzType = input("clazzType");
		if(!$examId) return [];
		$where["考试ID"] = $examId;
		$where["实验班"] = $clazzType;
		$result = Db::table("培优统计初一")
				  ->where($where)
				  ->order("班级")
				  ->select();
		$result = selectResult($result);
		//excel表头内容
		$list = explode(",", $fields);
		$header = [];
		foreach ($list as $key=> $value){
			$header[$value] = $value;
		}
		Excel::toExcel($result,'培优统计初一',$header);
		exit;
	}

	public function getFields(){
		$clazzType = input("clazzType");
	  	if($clazzType == 1) $fields = "班级,1-3,4-10,11-30,31-50,51-100,101-150,151-200,201-300,培优总分,培优名次";
	  	else if($clazzType == 2) $fields = "班级,1-3,4-10,11-30,31-50,51-100,101-150,151-200,培优总分,培优名次";
	  	else if($clazzType == 3) $fields = "班级,1-3,4-10,11-30,31-50,51-100,101-150,151-200,201-300,301-400,401-500,501-600,601-800,801-1000,1001-1200,培优总分,培优名次";
	 	else $fields = "班级,1-3,4-10,11-30,31-50,51-100,101-150,151-200,201-300,301-400,401-500,501-600,601-800,801-950,951-1100,培优总分,培优名次";
	  	return $fields;
	}

}
